package com.bestv.bsr.core.validate;

import org.apache.commons.lang3.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 自定义验证注解
 *
 * @author taojiacheng
 */
public class TvProfileValidator implements ConstraintValidator<TvProfile, String> {


    @Override
    public void initialize(TvProfile constraintAnnotation) {
    }

    @Override
    public boolean isValid(String tvProfile, ConstraintValidatorContext context) {
        if (StringUtils.isNotBlank(tvProfile)) {
            String[] tvProfiles = tvProfile.split(";");
            return tvProfiles[0].contains("FirmwareVersion/");
        }
        return true;
    }
}
